#include "SyntacticTree.h"
#include "assert.h"

double BinaryOperatorNode::Calculate() const
{
	double firstValue = first->Calculate();
	double secondValue = second->Calculate();
	switch (token.Type) {
	case Token::TT_BinaryAdd:
		return firstValue + secondValue;
	case Token::TT_BinarySubtract:
		return firstValue - secondValue;
	case Token::TT_Mult:
		return firstValue * secondValue;
	case Token::TT_Div:
		return firstValue / secondValue;
	default:
		assert(false);
		return 0;
	}
}
